package com.teaching.Dao;

import com.teaching.Enity.Learn;
import com.teaching.Enity.ScoreView;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class ScoreViewDaoAchieve implements ScoreViewDao {
    private SqlSession sqlSession;
    private String resource = "mybatis.xml";

    @Override//从数据库获取学生的成绩
    public List<ScoreView> GetScore(int s_id) throws IOException{
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        sqlSession = sessionFactory.openSession();
        List<ScoreView> scoreViewList=sqlSession.selectList("getScore",s_id);
        sqlSession.commit();
        sqlSession.close();
        return scoreViewList;
    }
}
